package com.pkk.penguin.frame.know.java.driven.ext.beanfactorypostprocess;

import com.alibaba.fastjson.JSONObject;
import com.pkk.penguin.frame.know.java.driven.ext.beanfactorypostprocess.bean.Blue;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

/**
 * 1. bean工厂后置处理器主测试类
 * {@link org.springframework.beans.factory.config.BeanPostProcessor} 是bean的后置处理器
 * {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor} 是beanFactory的后置处理器
 * 在BeanFactory初始化之后执行,所有的bean都被加载的BeanFactory中了,但是还没有被初始化
 *
 * @author peikunkun
 * @version V1.0
 * @date 2020-10-30 17:15
 **/
@ComponentScan("com.pkk.penguin.frame.know.java.driven.ext.beanfactorypostprocess")
public class BeanFactoryPostProcessMainTest extends AnnotationConfigApplicationContext {



  @Bean
  public Blue blue() {
    return new Blue();
  }

  public static void main(String[] args) {
    AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(
        BeanFactoryPostProcessMainTest.class);
    final Blue bean = (Blue) applicationContext.getBean("kunzaiName");
    System.out.println("结果:" + JSONObject.toJSONString(bean));
    applicationContext.close();

  }
}
